<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Pay</title>


    <link rel="stylesheet" type="text/css" href="../../static/layui/css/layui.css"/>
    <script type="text/javascript" src="../../static/layui/jquery-1.9.1.min.js"></script>

</head>

<body style="margin-left:5%; padding:1%;">
<br>

<div style="width: 90%">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
        <legend>订单详情</legend>
    </fieldset>

    <table class="layui-table" lay-skin="line">
        <colgroup>
            <col width="150">
            <col width="150">

        </colgroup>
        <thead>

        <tr>
            <th>订单号</th>
            <th>{{ data["tradeid"] }}</th>
            <input id="tradeid" value="{{ data["tradeid"] }}" type="hidden">
        </tr>

        </thead>
        <tbody>

        <tr>
            <td>用户账号</td>
            <td>{{ data["user_tel"] }}</td>
        </tr>

        <tr>
            <td>文件名称</td>
            <td>
                {#                {% for s in old_filenames %}#}
                {{ data["printfile"] }}
                {#                {% endfor %}#}
            </td>
        </tr>

        <tr>
            <td>订单时间</td>
            <td>{{ data['now'] }}</td>
        </tr>

        <tr>
            <td>应付金额</td>
            <td><b>{{ data["cost"] }}</b></td>
        </tr>

        <tr>
            <td>打印份数</td>
            <td><b>{{ data["print_copies"] }}</b></td>
        </tr>

        <tr>
            <td>打印点</td>
            <td><b>{{ data["print_place"] }}</b></td>
        </tr>

        <td>&nbsp;</td>
        <td align="center">
            <div class="layui-btn-group">
                <div class="site-demo-button" id="layerDemo"
                     style="margin-bottom: 0; width: 216px; margin: 0; white-space:nowrap;">
                    {% if identifi != 1 %}
                        <form action="{{ url_for('cloud_pay.ali_computerpay') }}" method="post">
                            <input type="hidden" name="tradeid" value="{{ data["tradeid"] }}">
                            <input type="hidden" name='tel_num' value="{{ data["user_tel"] }}">
                            <input type="hidden" name="print_name" value="{{ data["printfile"] }}">
                            <input type="submit" class="layui-btn" value="支付宝支付">
                            <button id='vx_pay' data-method="wechat" class="layui-btn">微 信 支 付</button>
                            {% if data["new_filename"][-3:] == "pdf" %}
                                <a class="layui-btn layui-btn-green" href='#'
                                   onclick="window.open('../admin/look_pdf/viewer.html?file=/static/Upload_Files/{{ data['new_filename'] }}','PDF','width:50%;height:50%;top:100;left:100;');">预览</a>
                            {% endif %}
                            {% if data['new_filename'][-3:] != "pdf" %}
                                <a class="layui-btn layui-btn-green" target="_blank"
                                   href="../admin/look_picture/{{ data['new_filename'] }}">预览</a>
                            {% endif %}
                        </form>
                    {% endif %}
                    {% if identifi == 1 %}
                        <form action="{{ url_for('cloud_pay.ali_mobilepay') }}" method="post">
                            <input type="hidden" name="tradeid" value="{{ data["tradeid"] }}">
                            <input type="hidden" name='tel_num' value="{{ data["user_tel"] }}">
                            <input type="hidden" name="print_name" value="{{ data["printfile"] }}">
                            <input type="submit" class="layui-btn" value="支付宝支付">
                            <button id='vx_pay' data-method="wechat" class="layui-btn">微 信 支 付</button>
                            {% if data["new_filename"][-3:] == "pdf" %}
                                <a class="layui-btn layui-btn-green" href='#'
                                   onclick="window.open('../admin/look_pdf/viewer.html?file=/static/Upload_Files/{{ data['new_filename'] }}','PDF','width:50%;height:50%;top:100;left:100;');">预览</a>
                            {% endif %}
                            {% if data['new_filename'][-3:] != "pdf" %}
                                <a class="layui-btn layui-btn-green" target="_blank"
                                   href="../admin/look_picture/{{ data['new_filename'] }}">预览</a>
                            {% endif %}
                        </form>
                    {% endif %}



                    {#                    {% for i in new_filenames %}#}

                    {#                    {% endfor %}#}
                </div>

            </div>
        </td>


        </tbody>
    </table>
</div>


<script type="text/javascript" src="../../static/layui/layui.js"></script>
<script>
    layui.use('layer', function () { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句

        //触发事件
        var active = {
            setTop: function () {
                var that = this;

            }

            , wechat: function () {
                $(function () {
                    $('#vx_pay').click(function () {
                        $.ajax({
                            url: '/jsons/js_pay',
                            dataType: 'json',
                            type: "post",
                            data: {
                                'name': '{{ data['printfile'] }}',
                                'pay_type': 'native',
                                'order_id': 'vxpay-' + '{{ data["tradeid"] }}',
                                'order_uid': '{{ data["user_tel"] }}',
                                'tradeid': '{{ data["tradeid"] }}'
                            },
                            success: function (data) {
                                layer.open({
                                    type: 1
                                    ,
                                    title: '微信支付'//不显示标题栏
                                    ,
                                    closeBtn: 2
                                    ,
                                    area: '350px;'
                                    ,
                                    shade: 0.5
                                    ,
                                    anim: 1
                                    ,
                                    id: 'wechat_pay' //设定一个id，防止重复弹出
                                    ,
                                    btn: ['重下订单', '确认支付']
                                    ,
                                    btnAlign: 'c'
                                    ,
                                    moveType: 1 //拖拽模式，0或者1
                                    ,
                                    content: "<div style='padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;'><img style='width: 90%;height: 90%;' src='../../static/pay_qrcode/" + data.url + ".jpg'></div>"
                                    ,
                                    success: function (layero) {
                                        var btn0 = layero.find('.layui-layer-btn');
                                        btn0.find('.layui-layer-btn0').attr({
                                            href: '/admin/select'
                                            , target: '_blank'
                                        });

                                        var btn1 = layero.find('.layui-layer-btn');
                                        btn1.find('.layui-layer-btn1').click(function () {
                                                $.ajax({
                                                        url: '/jsons/query_status',
                                                        dataType: 'json',
                                                        type: "post",
                                                        data: {
                                                            'aoid': data.aoid
                                                        },
                                                        success: function (quey_statu) {
                                                            if (quey_statu.quey_status == 'success') {
                                                                window.location.href = "/printer/select";
                                                                alert('支付成功,即将跳转到上传页面');
                                                            } else {
                                                                alert('支付失败')
                                                            }
                                                        }
                                                    }
                                                )
                                            }
                                        )
                                    }
                                })
                            }, //微信支付弹窗
                        })
                    })
                })
            }
            , offset:

                function (othis) {
                    var type = othis.data('type')
                        , text = othis.text();

                    layer.open({
                        type: 1
                        , offset: type
                        , id: 'layerDemo' + type //防止重复弹出
                        , content: '<div style="padding: 20px 100px;">' + text + '</div>'
                        , btn: '关闭全部'
                        , btnAlign: 'c' //按钮居中
                        , shade: 0 //不显示遮罩
                        , yes: function () {
                            layer.closeAll();
                        }
                    });
                }
        };

        $('#layerDemo .layui-btn').on('click', function () {
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });

    })
    ;
</script>


</body>
</html>
